import Vue from 'vue'
import Router from 'vue-router'
import staticRoutes from './static'
import axios from 'axios'
import apis from '../api/api'

Vue.use(Router)

const route =  new Router({
  routes: staticRoutes
})

// route.beforeEach( (to, from, next) => {
//   let token = localStorage.getItem('token');
//   let temUrl = window.location.href;
//   if(!token){
//     alert('start auth');
//     axios.post(apis.userCode, {
//       'url':temUrl
//     }).then(function(res){
//       window.location.href = res.data.msg;
//     }).catch(function(error){
//       alert(err);
//     })
//   }
// })

// route.beforeEach((to, from, next) => {
//   let distribution = localStorage.getItem('distribution');
//   let code = sessionStorage.getItem('code');
//   if(code){
//     next('/container/home');
//   }else{
//     next('/auth');
//   }
// })

export default route;

